﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 题库配置文件
/// </summary>
public class QuestionPool{
    public List<Question> questions = new List<Question>();

    public static QuestionPool Parse(string text)
    {
        QuestionPool questionPool = new QuestionPool();
        string[] lines = text.Split('\n');
        for (int i = 1; i < lines.Length; i++)
        {
            
            string[] items = lines[i].Split(',');
            if(items.Length < 4)
            {
                continue;
            }
            questionPool.questions.Add(new Question(items));
        }
        return questionPool;
    }
}

[Serializable]
public class Question {
    public string topic;
    public List<Option> options = new List<Option>();
    public int answer;

    public Question(string[] items)
    {
        topic = items[0];
        options.Add(new Option(items[1]));
        options.Add(new Option(items[2]));
        if (items[3].Trim().Equals("A"))
        {
            answer = 0;
        }
        else
        {
            answer = 1;
        }
    }
}

[Serializable]
public class Option {
    public string text;
    public Option(string text)
    {
        this.text = text;
    }
}

